/*
 * @Description:反序列化对象
 * 
 * @Author: rendc
 * 
 * @Date: 2024-10-15 15:00:50
 * 
 * @LastEditors: rendc
 * 
 * @LastEditTime: 2024-10-15 15:21:26
 */

import java.io.FileInputStream;
import java.io.ObjectInputStream;

/**
 * Test07
 */
public class Test07 {

  public static void main(String[] args) throws Exception {
    // 序列化对象
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream("/Users/cc/Desktop/Java/day33/Student.txt"));
    // 创建对象
    Student student = (Student) ois.readObject();
    // 写入次数和读取次数要保持一致 如果超出会抛异常
    Student student1 = (Student) ois.readObject();
    // 序列化
    System.out.println("对象反序列化成功" + student);
    System.out.println("对象反序列化成功" + student1);
    // 关闭流
    ois.close();
  }
}